﻿using System.Diagnostics.Contracts;
using System.IO;

namespace DaveSexton.Labs
{
	internal sealed class FolderObject : FileSystemInfo, IFolder
	{
		private readonly DirectoryInfo folder;

#if SILVERLIGHT
		[System.Security.SecuritySafeCritical]
		public FolderObject()
		{
			throw new System.NotSupportedException();
		}
#endif

		public FolderObject(string path)
		{
			Contract.Requires(path != null);

			this.folder = new DirectoryInfo(path);
		}

		[ContractInvariantMethod]
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Required for code contracts.")]
		private void ObjectInvariant()
		{
			Contract.Invariant(folder != null);
		}

		public override bool Exists
		{
			get
			{
				return folder.Exists;
			}
		}

		public override string FullName
		{
			get
			{
				return folder.FullName;
			}
		}

		public override string Name
		{
			get
			{
				return folder.Name;
			}
		}

		public override void Delete()
		{
			folder.Delete();
		}

		public override string ToString()
		{
			return folder.ToString();
		}
	}
}